import random
import numpy as np
import requests

#初始化变量
user_name = ''
user_hash = 0
t = ''
ip_list = []

#获取公网ip
def get_public_ip():
    try:
        # 请求一个提供公网IP的API
        response = requests.get("https://ipinfo.io/json")
        response.raise_for_status()  # 检查请求是否成功
        data = response.json()
        public_ip = data["ip"]
    except requests.RequestException as e:
        print("获取公网IP失败:", e)
        return None
    return public_ip

#主体
while 1:
    ip = get_public_ip()
    t = input('请操作：')
    if (t == "0"):
        if(ip in ip_list):
            print("禁止重复注册！")
        else:
            tele = input('请输入手机号：')
            #获取验证码
            print('验证码：')
            num = input()
            rand = random.uniform(1.234, 999)#加密
            tele += str(rand)
            user_hash = abs(hash(tele))
            print('注册成功！您的账号是：',user_hash)
            ip_list.append(get_public_ip())
    elif(t == "1"):
        #扫描
        print("扫描完毕")
    elif(t == "2"):
        print("以下是你的美食图谱：")
    elif(t == "3"):
        print("以下是你的个人信息：")
        print("等级：0 用户名：111 账号：000 上传数：0 交换数：0")
    elif(t == "4"):
        print("欢迎来到美食广场，以下是推荐给你的美食图谱：")
    elif(t == "-1"):
        break